class Solution {
    public boolean isValid(String s) {
        //使用栈的方式去完成这道题；
        Stack<Character> stack = new Stack<>();
        //把String转化成CharArray节省计算时间
        //循环亚入栈中
        for( char c:s.toCharArray()){
            if( c == '('){
                stack.push(')');
            }else if( c == '{'){
                stack.push('}');
            }else if( c == '['){
                stack.push(']');
            }else{
                if (stack.isEmpty()){
                    return false;
                }else
                if(stack.pop() != c){
                    return false;
                }
            }
        }
        return stack.isEmpty();
    }
}

public class MainClass {
    public static String stringToString(String input) {
        if (input == null) {
            return "null";
        }
        return Json.value(input).toString();
    }
    
    public static String booleanToString(boolean input) {
        return input ? "True" : "False";
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            String s = stringToString(line);
            
            boolean ret = new Solution().isValid(s);
            
            String out = booleanToString(ret);
            
            System.out.print(out);
        }
    }
}